package com.evon.yardmanagement.transformer;

import java.util.ArrayList;
import java.util.List;

import org.dozer.DozerBeanMapper;

import com.evon.yardmanagement.model.User;
import com.evon.yardmanagement.ui.dto.transaction.UserDTO;

public class UserTransformer {
	static DozerBeanMapper mapper = new DozerBeanMapper();

	public static UserDTO transformToDTO(User user) {
		UserDTO userDTO = new UserDTO();
		mapper.map(user, userDTO);
		return userDTO;
	}

	public static List<UserDTO> transformToDTO(List<User> users) {
		List<UserDTO> userDTOList = new ArrayList<UserDTO>();
		for (User userObj : users) {
			UserDTO roleDTO = new UserDTO();
			mapper.map(userObj, roleDTO);

			userDTOList.add(roleDTO);
		}

		return userDTOList;
	}

	public static User transformToModel(UserDTO userDTO) {
		User user = new User();
		mapper.map(userDTO, user);
		return user;
	}

}
